import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashSet;
import java.util.Scanner;

public class Demo {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader("temp.txt"));
        Scanner sc = new Scanner(System.in);
        HashSet<String> hs = new HashSet<>();
        String s;
        while((s = br.readLine())!=null){
            hs.add(s);
        }
        while(!(s = sc.next()).equals("886")){
            System.out.println(hs.contains(s));
        }
        br.close();
        sc.close();
    }
}
